<template>
  <div id="app">
   测试
   <h1>{{sum}}</h1>
   <!-- 引用mutations来修改state的数据 -->
  <h1><button @click="setSum(1)">点击加1</button></h1>
  <h1><button @click="asyncSetSum(33)">点击延迟加33</button></h1>
  </div>
</template>

<script>
//引入mapState优化数据
import {mapState,mapMutations,mapActions} from 'vuex'

export default {
  computed:{
    ...mapState(['sum'])
  },
  methods:{
   ...mapMutations(['setSum']),

   ...mapActions(['asyncSetSum'])
  }

 
}
</script>

<style>
#app {
 
}
</style>
